<%@ page import="cn.bai.mvc.Customer" %>
<%@ page import="java.util.List" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Admin
  Date: 12/23 0023
  Time: 23:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form action="query.do" method="post">
    <table>
        <tr>
            <td>Name:</td>
            <td><input type="text" name="name"/></td>
        </tr>
        <tr>
            <td>Address:</td>
            <td><input type="text" name="address"/></td>
        </tr>
        <tr>
            <td>Phone:</td>
            <td><input type="text" name="phone"/></td>
        </tr>
        <tr>
            <td><input type="submit" value="查询"/></td>
            <td><a href="/page/newcustomer.jsp">Add New Customer</a></td>
        </tr>
    </table>
</form>

<br><br><hr><br><br>

<c:if test="${! empty requestScope.customers}">
<table border="1" cellpadding="10" cellspacing="0">
    <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Address</th>
        <th>Phone</th>
        <th>Update\Delete</th>
    </tr>
    <c:forEach items="${requestScope.customers}" var="cus">
    <tr>
        <td>${cus.id}</td>
        <td>${cus.name}</td>
        <td>${cus.address}</td>
        <td>${cus.phone}</td>
        <td>
            <c:url value="/edit.do" var="editValue">
                <c:param name="id" value="${cus.id}"></c:param>
            </c:url>
            <c:url value="/delete.do" var="deleteValue">
                <c:param name="id" value="${cus.id}"></c:param>
            </c:url>
            <a href="editValue">Update</a>
            <a href="deleteValue">Delete</a>
        </td>
    </tr>
    </c:forEach>
</table>
</c:if>

<script type="text/javascript" src="/jquery-1.7.2.js"></script>
<script type="text/javascript">
    $(function () {
        $(".delete").click(function(){
            var contain=$(this).parent().parent().find("td:eq(1)").text();
            var flag=confirm("确定要删除"+contain+"信息吗?");
            return flag;
        })
    })
</script>
</body>
</html>
